package site.codeyin.javautils.utils.optional;

import java.util.Optional;

/**
 * @author <a href="https://github.com/liangcheng2221">yinjie</a>
 * @date 2024-09-21 12:27
 */
public class Main {
    public static void main(String[] args) {
        System.out.println(Optional.of("yinjie").orElse("exception"));
        System.out.println(Optional.of("yinjie").orElseGet(()-> "123"));
//        System.out.println(Optional.empty().orElseThrow(() -> new RuntimeException("exception")));
        Optional.of("yinjie").ifPresent(System.out::println);
        Optional.of("yinjie").filter(s -> s.equals("yinjie")).ifPresent(System.out::println);
    }
}
